package flc.ast.utils;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.SPUtils;
import com.google.gson.reflect.TypeToken;

import java.util.List;

import flc.ast.bean.ClockInBean;
import flc.ast.bean.CycleBean;
import flc.ast.bean.HourWageBean;


public class AppSpUtils {
    private static final String SP_NAME = "appCollSp";
    private static final SPUtils sSpUtils = SPUtils.getInstance(SP_NAME);

    public static void saveWageList(List<HourWageBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_hour_wage_list, json);
    }

    public static List<HourWageBean> getWageList() {
        String json = sSpUtils.getString(Key.key_hour_wage_list);
        return GsonUtils.fromJson(json, new TypeToken<List<HourWageBean>>() {
        }.getType());
    }

    public static void saveClockInList(List<ClockInBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_clock_in_list, json);
    }

    public static List<ClockInBean> getClockInList() {
        String json = sSpUtils.getString(Key.key_clock_in_list);
        return GsonUtils.fromJson(json, new TypeToken<List<ClockInBean>>() {
        }.getType());
    }

    public static void saveCycleList(List<CycleBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_cycle_list, json);
    }

    public static List<CycleBean> getCycleList() {
        String json = sSpUtils.getString(Key.key_cycle_list);
        return GsonUtils.fromJson(json, new TypeToken<List<CycleBean>>() {
        }.getType());
    }

    interface Key {
        String key_hour_wage_list = "key_hour_wage_list";
        String key_clock_in_list = "key_clock_in_list";
        String key_cycle_list = "key_cycle_list";

    }
}